/*<summary>
Created By : Preeti
Created On : 9/20/2008
Class Name : PatientBilling_LoadMapper
Used In    : 
------------------------------------------------------------------------
Modification Log  
------------------------------------------------------------------------
Created By        Modified By         Remarks                             
-----------       ------------        ----------------------------------
                                                                          
------------------------------------------------------------------------
</summary>*/


using System.Xml;
using System.Data;
using System;
using Utils;
using System.Data.SqlClient;

namespace InPatientCntroller
{
    public class PatientBilling_DataLoader
    {
        public PatientBilling Get_PatientBilling_DATA(string ID)
        {
            PatientBilling objPatientBilling = new PatientBilling();
            ezUtilsAdapter DBL = new ezUtilsAdapter();
            DataChecker dtc = new DataChecker();
            DataSet ds = new DataSet();


            try
            {
                ds = DBL.RunSPReturnDataSet("SP_GetPatientBilling", "TR", new SqlParameter("@vchID", ID));
                if (ds.Tables[0].Rows.Count > 0)
                {
                    DataRow dr = ds.Tables[0].Rows[0];
                    objPatientBilling.CRNumber = Convert.ToString(dr["CRNumber"]);
                    objPatientBilling.RcptNumber = Convert.ToString(dr["RcptNumber"]);
                    objPatientBilling.ChargeType = Convert.ToString(dr["ChargeType"]);
                    objPatientBilling.Quantity = Convert.ToDouble(dr["Quantity"]);
                    objPatientBilling.Rate = Convert.ToDouble(dr["Rate"]);
                    objPatientBilling.Amount = Convert.ToDouble(dr["Amount"]);
                    objPatientBilling.AmountPaid = Convert.ToDouble(dr["AmountPaid"]);
                    objPatientBilling.DiscountType = Convert.ToString(dr["DiscountType"]);
                    objPatientBilling.RecomandedBy = Convert.ToString(dr["RecomandedBy"]);
                    return objPatientBilling;
                }
                else
                {
                    return objPatientBilling;
                }
            }
            catch (SqlException ex)
            {
                string errorMessage = String.Format(
                    "An Error Occurred While Loading the PatientBilling Information to the DB. Message: {0}", ex.Message);
                return objPatientBilling;
            }
            finally
            {
                DBL.Dispose();
                dtc.Dispose();
                ds.Dispose();

            }
        }

        public void Dispose()
        {
            this.Dispose(true);
            System.GC.SuppressFinalize(this);
        }

        private void Dispose(bool disposing)
        {
        }


    }
}